class Task44:
    def run(self, n):
        digits = 1
        index = n
        m = self.get_number_of_digits(digits) * digits
        while index >= m:
            index -= m
            digits += 1
            m = self.get_number_of_digits(digits) * digits
        return self.run_based_on_digits(digits, index)

    def run_based_on_digits(self, digits, index):
        skip = index // digits
        offset = index % digits
        num = self.get_num_by_digits_and_skip(digits, skip)
        num = str(num)
        return int(num[offset])

    def get_num_by_digits_and_skip(self, digits, skip):
        if digits == 1:
            base = 0
        else:
            base = int(10 ** (digits - 1))
        return base + skip

    def get_number_of_digits(self, digits):
        if digits == 1:
            return 10
        return int(10 ** (digits - 1)) * 9
